cmake_minimum_required(VERSION 3.1)
project(StableDiffusionNCNN)

set(DEBUG                   true)
set(OPTIMIZATION_LEVEL      0)

set(IS_SHOW_IMAGE true)

set(BIN_NAME "stable-diffusion-ncnn")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

FIND_PACKAGE(OpenCV 4 REQUIRED)
FIND_PACKAGE(ncnn REQUIRED)

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)

FILE(GLOB_RECURSE sourcefiles "src/*.cpp")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O${OPTIMIZATION_LEVEL}")

IF(DEBUG)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
    ADD_COMPILE_DEFINITIONS(DEBUG)
ENDIF()

ADD_EXECUTABLE(${BIN_NAME} ${sourcefiles})

TARGET_LINK_LIBRARIES(${BIN_NAME} ${OpenCV_LIBS})
TARGET_LINK_LIBRARIES(${BIN_NAME} ncnn)

FILE(COPY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR})
